/**
* Created by Administrator on 2025/5/7.
* */
#include "AppDelegate.h"
#include "GlobalParameters.h"
#include <string>
#include "DataDispatcher/DataDispatcher.h"
#include "MyDeviceReader/MyDeviceReader.h"
#include "SignalSource/SignalSource.h"
#include "ClutterSource/ClutterSource.h"
#include "NoiseSource/NoiseSource.h"
#include "InterferenceSource/InterferenceSource.h"
#include "VirtualTarget/VirtualTarget.h"
#include "EthernetReader.h"
#include "MyDeviceWriter/MyDeviceWriter.h"

void AppDelegate::onConfigure(device_config_t *config){
    config->calculationPoolSize=8;
    config->globalParametersInstance = GlobalParameters::shareInstance();
    config->deviceId=2;
    config->servicePort=55261;
    config->ip="192.168.1.115";
    config->userVersion="1.0";
}

void AppDelegate::onStart(){
    REGISTER_RUNTIME_LOADED_CLASSES(DataDispatcher,MyDeviceWriter,SignalSource,MyDeviceReader,ClutterSource,NoiseSource,InterferenceSource,VirtualTarget);
    auto dataDispatcher = new DataDispatcher();
    auto signalSource = new SignalSource();
    auto clutterSource = new ClutterSource();
    auto noiseSource = new NoiseSource();
    auto interferenceSource = new InterferenceSource();
    auto virtualTarget = new VirtualTarget();

    auto radarlabReader = new MyDeviceReader();
    radarlabReader->addTaskModule(signalSource,0,1024);
    radarlabReader->addTaskModule(clutterSource,0,1024);
    radarlabReader->addTaskModule(noiseSource,0,1024);
    radarlabReader->addTaskModule(interferenceSource,0,1024);

    auto radarlabReader_1 = new EthernetReader(TCP,6690);
    radarlabReader_1->addTaskModule(dataDispatcher,0,1024);

    auto radarlabReader_3 = new EthernetReader(TCP,6692);
    radarlabReader_3->addTaskModule(signalSource,2,1024);

    auto radarlabReader_2 = new EthernetReader(TCP,6694);
    radarlabReader_2->addTaskModule(signalSource,1,1024);

    auto radarlabWriter_3 = new MyDeviceWriter();
    dataDispatcher->addDeviceWriter(3,radarlabWriter_3,1024);

    auto radarlabWriter_2 = new MyDeviceWriter();
    dataDispatcher->addDeviceWriter(2,radarlabWriter_2,1024);

    auto radarlabWriter = new MyDeviceWriter();
    dataDispatcher->addDeviceWriter(0,radarlabWriter,1024);

    auto radarlabWriter_1 = new MyDeviceWriter();
    dataDispatcher->addDeviceWriter(1,radarlabWriter_1,1024);

    auto radarlabWriter_4 = new MyDeviceWriter();
    dataDispatcher->addDeviceWriter(5,radarlabWriter_4,1024);

    auto radarlabWriter_5 = new MyDeviceWriter();
    dataDispatcher->addDeviceWriter(4,radarlabWriter_5,1024);

    signalSource->addOutput(0,0,virtualTarget,1024);
    clutterSource->addOutput(0,1,virtualTarget,1024);
    noiseSource->addOutput(0,2,virtualTarget,1024);
    interferenceSource->addOutput(0,3,virtualTarget,1024);
    virtualTarget->addOutput(0,1,dataDispatcher,1024);
    REGISTER_INSTANCES(dataDispatcher,radarlabReader_1,radarlabWriter,radarlabWriter_1,radarlabWriter_2,radarlabWriter_3,radarlabWriter_5,radarlabWriter_4,signalSource,radarlabReader);
    REGISTER_INSTANCES(radarlabReader_2,radarlabReader_3,clutterSource,noiseSource,interferenceSource,virtualTarget);
}
